<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>统计字符串中某个字符出现的次数</title>
</head>
<body>
  <script>
    var arr = 'abcdefacjkathma'
    // 分割成数组
    arr.split('')
    var res = 0
    // 遍历数组
    for(let i in arr) {
      // 判断有多少个a
      if(arr[i] == 'a') {
        res++
      }
    }
    console.log(res)
  </script>
</body>
</html>